/*
 * Polygon
 * 
 * initial implementation : 4.9.2007
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using Petra.Gis.Geometry.Support;


namespace Petra.Gis.Geometry
{
  /// <summary>
  /// Polygon geometry to store polygon, including holes
  /// input geometry types is limited to LineRing and PathRing
  /// </summary>
  public class Polygon : GeometryCollection
  {

    public Polygon()
    {
      System.Type[] _tl = {
                           typeof(LineRing),
                           typeof(PathRing)
                          };
      typeLimits = _tl;
    }



    //must validate if next component inside of first, not implemented now
    /*public override void Add(IAreaComponent oGeom)
    {      
      base.Add(oGeom);
    }*/




    public GeometryBase Exterior {
      get { return this[0]; }
      /*set { 
        //todo: make validation
        this[0] = value; 
      
      }*/
    }





    public MultiArea Holes
    {
      get {
        //create Holes Collection onfly ;-)
        MultiArea tmp = new MultiArea();
        for (int i = 1; i < this.Count; i++ )
          tmp.Add(this[i]);
        return tmp;
      }
      /*set
      {
        //todo: make validation
        this[0] = value;

      }*/
    }





    //polygon can test first ring only, all next rings must be inside of outer boundary ;-)
    internal override BoundingBox getEnvelope()
    {
      //get first geometry envelope
      return this[0].getEnvelope();
    }



  }
}
